public class RegularEmployee extends Employee {
    private final double hourlyRate;
    private double workHours;

    public RegularEmployee(String name, String empId, double hourlyRate, double workHours) {
        super(name, empId);
        this.hourlyRate = hourlyRate;
        this.workHours = workHours;
    }

    @Override
    public double calculateSalary() {
        if (workHours < 0 || workHours > 168) {
            System.out.println("警告：" + getEmpId() + getName() + "工作时长异常（合法0-168小时），按0薪资计算");
            return 0.0;
        }
        return hourlyRate * workHours;
    }

    @Override
    public String generatePaySlip() {
        return super.generatePaySlip() + String.format("\n明细：时薪%.2f元 × 工作%.2f小时",
                hourlyRate, workHours);
    }
}